# from common.models.thing_order import ThingOrder
# from common.libs.DataHelper import getCurrentDate
# from common.models.seal_order import SealOrder
# from common.models.user import User
# from common.models.department import Department
# from common.models.user import User
# from common.models.thing_list import Thinglist
# from common.models.mail_address import MailAddress
# from common.models.eating_menu import EatingMenu
from common.libs.DataHelper import getCurrentTime
from datetime import date, timedelta
import datetime
import requests

# import datetime
# import json
# from sqlalchemy import func
# from application import db
# from common.models.employ_list import EmployList
# from common.models.employ_order import EmployOrder
# import json, requests
# import requests
# import urllib.request
#
# a = EmployOrder.query.filter_by(id=1).first()
# openid = a.creater.openid
# appID = 'wx15624353af4493ad'  # 开发者关于微信小程序的appID
# appSecret = 'd7f09203305d4afe4716c0bdaa6fe7c7'  # 开发者关于微信小程序的appSecret
# req_params = {
#     'appid': appID,
#     'secret': appSecret,
#     'grant_type': "client_credential"
# }
# wx_login_api = 'https://api.weixin.qq.com/cgi-bin/token?'
# response_data = requests.get(wx_login_api, params=req_params)  # 向API发起GET请求
# resData = response_data.json()
# token = resData['access_token']  # 得到用户关于当前小程序的OpenID
#
# data = {
#     "touser": openid,
#     "template_id": "RhQmy-1ihsDn84GG8VF8rS9YA5-097o9vDT5ZaPyxnQ",
#     # "page": "pages/seal/sealmeg?pdnum=" + str(id),
#     "page": "index",
#     "miniprogram_state": "developer",
#     "lang": "zh_CN",
#     "data": {
#         "thing1": {
#             "value": "您举荐的人才已通过面试"
#         },
#         "time3": {
#             "value": "2020-04-05"
#         },
#         "thing3": {
#             "value": "您的人才举荐奖，请及时查收"
#         },
#     }
# }
#
# url = 'https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token={serverToken}'.format(
#     serverToken=token)
# # 数据格式化(从这里开始对上面的data进行格式化,转成符合post的json参数形式)
# data = json.dumps(data)
# # 数据格式化
# data = bytes(data, 'utf8')
# # 数据格式化
#
# request1 = urllib.request.Request(url)
# # post服务器请求
# result = urllib.request.urlopen(request1, data).read()
#
# # 打印结果
# newresult = json.loads(result)
# errcode = newresult['errcode']
# print(newresult)

# tody=date.today()
# tomorrow = (date.today() + timedelta(days= 1)).strftime("%Y-%m-%d")
# tomorrow = (date.today() + timedelta(days=1)).strftime("%Y-%m-%d")
# year = int(tomorrow[0:4])
# month = int(tomorrow[5:7])
# day = int(tomorrow[8:10])
# week = datetime.datetime(year,month,day).isoweekday()
# print(year,month,day,week)

url = "https://devapi.qweather.com/v7/weather/now?location=101100101&key=b632b25bd3c949e79704c47dad5e8607"

rep = requests.get(url)
rep.encoding = 'utf-8'
repJson = rep.json()
weather =repJson.get('now')
text=weather["text"]
icon=weather["icon"]
temp=weather["temp"]
feelsLike=weather["feelsLike"]
windDir=weather["windDir"]
humidity=weather["humidity"]

weatherinfo = text+" "+windDir+"    温度:"+temp+"℃    体感温度:"+feelsLike+"℃    相对湿度:"+humidity+"%"
print(weatherinfo)